<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class tagboard {
    var $id;
var $date_time;
var $visitor_name;
var $messages;


    function open(){
        global $db;
        $sql="select * from _tagboard where id=$id";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->date_time=$date_time;
$this->visitor_name=$visitor_name;
$this->messages=$messages;

        }
    }

    function openAll(){
        $sql="select * from _tagboard order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into _tagboard values (null,sysdate(),
'{$this->visitor_name}',
'{$this->messages}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update _tagboard set date_time='{$this->date_time}',
visitor_name='{$this->visitor_name}',
messages='{$this->messages}',
 where id={$this->id}";
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from _tagboard where id=".$this->id;
        $db->query($sql);
    }

}
?>
